home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / comm / www / cache2file.lha / Cache2file.p < prev   
Text File  |  2000-09-26  |  4KB  |  178 lines

  1. ; (c) 2000 Cyborg 
  2.  
  3.     {* Include sys:coder/preass/Options.p *}
  4.     {* Include sys:coder/preass/Prozeduren.p *}
  5.  
  6.     {* String: Version="$VER: (C) CYBORG 2000"*}
  7.     
  8.     {* IncBlock: Seekpattern,250*}
  9.  
  10.  
  11. LastSign[a0]:
  12.     cmpi.b #0,(a0)+
  13.     bne LastSign
  14.     lea -2(a0),a0
  15.     cmpi.b #"/",(a0)
  16.     bne .rts
  17.     move.l #"/ind",(a0)+
  18.     move.l #"ex.h",(a0)+
  19.     move.l #$746d6c00,(a0)+
  20. .rts:
  21.     rts
  22.  
  23.  
  24. CopyFile[a0,a1]:
  25.     {* StackFrame in,out,anz,InName=a0,Outname=a1*}
  26.     movea.l a1,a2
  27.     moveq.l #0,d7
  28. .l0:
  29.     cmpi.b #0,(a2)
  30.     beq .l1
  31.     cmpi.b #":",(a2)
  32.     beq .l02
  33.     cmpi.b #"?",(a2)
  34.     beq .l02
  35.     cmpi.b #"/",(a2)
  36.     bne .l01
  37.     addq.l #1,d7
  38. .l01:
  39.     lea 1(a2),a2
  40.     bra .l0
  41. .l02:
  42.     move.b #"_",(a2)
  43.     bra .l0
  44. .l1:
  45.     cmpi.l #0,d7
  46.     beq .ende
  47. ;    subq.l #1,d7
  48.     moveq.l #0,d6
  49. .l2:
  50.     addq.l #1,d6
  51.     cmpi.l d6,d7
  52.     beq .Copy
  53.     moveq.l #0,d5
  54.     move.l Buffer2,a3
  55.     move.l a1,a2
  56.     cmpi.l #"http",(a2)
  57.     bne .ftp
  58.     move.l #"p__/",3(a2)
  59.     bra .los
  60. .ftp:
  61.     move.l #"p__/",2(a2)
  62. .los:
  63.     cmpi.b #"/",(a2)
  64.     bne .l3
  65.     addq.l #1,d5
  66.     cmp.l d5,d6
  67.     beq .makedir
  68. .l3:
  69.     move.b (a2)+,(a3)+
  70.     bra .los
  71. .makedir:
  72.     move.b #0,(a3)+
  73.     push d0-a5
  74.     If Createdir(buffer2)#0
  75.      {
  76.        unlock(d1)
  77.      }
  78.     pop d0-a5
  79.     bra .l2
  80. .copy:
  81.     Printf("%s\n",*OutName)
  82.     lastsign(outname)
  83.     If (in=open(InName,mode_old))#0
  84.      {
  85.       if (out=open(OutName,mode_new))#0
  86.         {
  87.           anz==10000
  88.           While anz=10000
  89.            {
  90.             anz=Read(in,Filebuffer,10000)
  91.             Write(out,Filebuffer,anz)
  92.            }
  93.           Close(out)
  94.         }
  95.       close(in)
  96.      }
  97. .ende:
  98.     {* Unframereturn *}
  99.  
  100. ceol[a0]:
  101.     cmpi.b #$0a,(a0)
  102.     bne .l1
  103.     move.b #0,(a0)
  104. .l1:cmpi.b #0,(a0)+
  105.     bne ceol
  106.     rts
  107.     
  108.  
  109. Start:
  110. ;    copymem("www.garfield.com",&Filename,?)
  111.     buffer=malloc(1024)
  112.     buffer1=malloc(1024)
  113.     Buffer2=malloc(200)
  114.     If Getfilename()#0 
  115.      {
  116.        grep==1
  117.        Copymem(&Filename,&Seekpattern,250)        
  118.      }
  119.     FileBuffer=malloc(10000)
  120.     If (Filehandle=Open("env:Aweb3/network",mode_old))#0
  121.      {
  122.        While Fgets(Filehandle,Buffer,1024)#0
  123.         {
  124.           Wort=.l0(Buffer)
  125.           if Wort=#"CAPA" 
  126.            {
  127.              Copymem(Buffer+5,&Filename,240)
  128.              ceol(&Filename)
  129.            }
  130.         }
  131.        Close(Filehandle)
  132.        FIB=malloc(400)
  133.        FIB1=malloc(400)
  134.        FillBuffer(FIB,0,400)
  135.        FillBuffer(FIB1,0,400)
  136.        FillBuffer(Buffer,0,1024)
  137.        If (Dirlock=Lock(&Filename,Access_read))#0 
  138.         {
  139.           OK=Examine(Dirlock,FIB)
  140.           While Exnext(Dirlock,FIB)#0
  141.            {
  142.              type=.l4(FIB)
  143.              if type>0 
  144.               {
  145.                zeiger=8(FIB)
  146.                Copymem(&Filename,Buffer,250)
  147.                addpart(buffer,zeiger,1024)
  148.                FillBuffer(Buffer1,0,1024)
  149.                If (Dirlock1=Lock(Buffer,Access_read))#0
  150.                 {
  151.                   FillBuffer(Buffer1,0,1024)
  152.                   OK=Examine(Dirlock1,FIB1)
  153.                   While Exnext(Dirlock1,FIB1)#0
  154.                    {
  155.                     zeiger=8(FIB1)
  156.                     Copymem(Buffer,Buffer1,250)
  157.                     addpart(buffer1,zeiger,1024)
  158.                     zeiger=144(FIB1)
  159.                     If Grep=0 
  160.                      {
  161.                       CopyFile(Buffer1,Zeiger)
  162.                      }
  163.                     If grep=1 and Stringfind(Zeiger,&Seekpattern)#0
  164.                      {
  165.                       CopyFile(Buffer1,Zeiger)
  166.                      }
  167.                    }
  168.                   UnLock(Dirlock1)
  169.                 }
  170.               }
  171.             }
  172.           UnLock(Dirlock)
  173.         }
  174.      }
  175.     {* Return *}
  176.